package edu.scsu.csci;

import edu.scsu.csci.converter.ConversionException;

/**
 * <p> Interface to be implemented by all the convertors defined for the application. </P>
 * 
 * <p> A convertor is responsible for mapping and then converting the HTTP request parameters
 * 	   to the appropriate fileds of the domain object.
 * 
 * <p> A user defined convertor should be defined in the webconfig file as
 * 	   <code>
 * 			<convertor>
 *			    <objectType>java.lang.String</objectType>
 *			    <convertorClass>edu.scsu.csci.converter.StringConverter</convertorClass>
 *			</convertor>
 *	   </code>
 *	   <b>or</b> can also be configured directly by
 *	   <code> 
 *			ConvertorRegistry.getInstance().register(objectType, convertorClazz));
 *		</code>
 * </p>
 *
 * <p>	The prefered way to register a convertor is to do it through the configuration
 *		file as this promotes more loose coupling with the framework. </p>
 *
 * @author Maqbool Khan
 * @since jdk 1.5
 * @see
 * @viz.diagram IConverter.tpx
 */
public interface IConverter<T> {

	/**
	 * Converts a value to an specific type
	 * 
	 * @param value           		  current value
	 * @param type            		  desired type
	 * @return 				  		  the converted value
	 * @throws ConversionException    some conversion problem occurred
	 */
	public T convert(String value, Class<?> type)	throws ConversionException;

}
